package com.jilefojing.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import tk.mybatis.mapper.entity.Example;

import com.jilefojing.beans.enums.ItemTypeEnumForSource;
import com.jilefojing.beans.pojos.Statistics;
import com.jilefojing.dao.IStatisticsDao;
import com.jilefojing.dao.base.impl.BaseDao;
import com.jilefojing.dao.mapper.IStatisticsMapper;

/**
 * 
 * @author 作者 jgshun
 * @date 创建时间 2016年07月19日 20时40分29秒
 */
@Repository
public class StatisticsDao extends BaseDao<Statistics> implements IStatisticsDao {
	@Autowired
	private IStatisticsMapper statisticsMapper;

	@Override
	public List<Statistics> getListByItems(ItemTypeEnumForSource itemType, List<Long> itemIds) {
		Example example = new Example(Statistics.class);
		example.createCriteria().andEqualTo(Statistics.FIELD_ITEMTYPE, itemType.getCode()).andIn(Statistics.FIELD_ITEMID, itemIds);
		return super.getListByExample(example);
	}

	@Override
	public Statistics getByItem(ItemTypeEnumForSource itemType, Long itemId) {
		Statistics record = new Statistics();
		record.setItemId(itemId);
		record.setItemType(itemType.getCode());
		return super.getOneByRecord(record);
	}

	@Override
	public void updateCount(long id, String updateColumn, boolean plus, int value) {
		statisticsMapper.updateCount(id, updateColumn, plus, value);
	}

	@Override
	public List<Statistics> getListForNotEntitys(ItemTypeEnumForSource itemType, Map<Long, List<Long>> notEntityMaps) {
		return statisticsMapper.getListForNotEntitys(itemType, notEntityMaps);
	}

}
